<?php

namespace App\Console\Commands;

use App\Jobs\SendSmsJob;
use App\Services\UserService;
use Illuminate\Console\Command;

class SendSms extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'SendSms';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '发送短信任务';

    protected $userService;

    /**
     * SendSms constructor.
     * @param UserService $userService
     */
    public function __construct(UserService $userService)
    {
        parent::__construct();

        $this->userService = $userService;
    }

    /**
     * 定时发送短信
     * @return mixed
     */
    public function handle()
    {
        SendSmsJob::dispatch($this->userService->sendSms())->onQueue('sendSmsJob')->delay(10);
    }
}
